<template>
  <div class="pat_info">
    <div class="grid_tit">
      <div class="flex flex-row align-center pad-b-6 mar-t-10">
        <div class="mar-l-3 font-bold">申请单信息</div>
        <div class="ky-fr flex flex-row align-center mar-l-10">
          <el-tag
            v-if="rowCurr.emergency"
            size="mini"
            effect="dark"
            type="danger"
          >{{rowCurr.emergencylabel}}</el-tag>
          <div>
            <el-tag
              v-if="rowCurr.patientName"
              :title="rowCurr.emergencylabel"
              size="mini"
              effect="dark"
              :type="rowCurr.emergency > 0 ? 'danger':'warn'"
            >{{rowCurr.patientName}}</el-tag>
            <span>{{rowCurr.genderTxt}} {{rowCurr.patAgeTxt}}</span>
          </div>
        </div>
      </div>
    </div>
    <div class="pat_info_item mar-t-6">
      <!-- <AppInfoItem label="P I D 号" v-if="mipVisible == false" :txt="rowCurr.patientId" style="width: 50%"/> -->
      <!-- <AppInfoItem label="P  I  D 号" v-else :txt="rowCurr.masterPatientIndexId" style="width: 50%"/> -->
      <AppInfoItem :label="rowCurr.visit && rowCurr.visit.patientSource ? (getSource('','',rowCurr.visit.patientSource) === '体检' ? '体检号码' : (getSource('','',rowCurr.visit.patientSource) === '住院' ? '住院号码' : (getSource('','',rowCurr.visit.patientSource) === '门诊' ? '门诊号码': 'P  I  D 号'))) : 'P  I  D 号'" style="width: 50%">
        <span>{{rowCurr.patientId}}</span>
      </AppInfoItem>
      <AppInfoItem label="病人类型" style="width: 50%">
        <span>{{rowCurr && rowCurr.visit ? getSource('','',rowCurr.visit.patientSource) : getSource('','',rowCurr && rowCurr.patientSource)}}</span>
      </AppInfoItem>
      <AppInfoItem label="出生日期" :txt="rowCurr.birthDate" style="width: 50%"/>
      <AppInfoItem label="身份证号" :txt="rowCurr.idCard" style="width: 50%"/>
      <AppInfoItem label="联系方式" :txt="rowCurr.patientPhone" style="width: 50%"><i class="el-icon-edit" @click="editPhone(rowCurr.patientPhone)" title="修改联系方式" style="cursor: pointer;"></i></AppInfoItem>
      <!-- 新增地址信息 -->
      <AppInfoItem label="优惠类型" :txt="rowCurr.feeType" style="width: 50%"/>
      <AppInfoItem label="申请医生" :txt="rowCurr.applyDoctor" style="width: 50%"/>
      <AppInfoItem label="申请科室" :txt="rowCurr.applyDepartment" style="width: 50%"/>
      <AppInfoItem label="申请时间" :txt="rowCurr.applyDateTime" style="width: 50%"/>
      <AppInfoItem label="检查目的" :txt="rowCurr.examPurpose" style="width: 50%"/>
      <AppInfoItem label="检查项目" :txt="rowCurr.examItemName" style="width: 50%"/>
      <AppInfoItem label="检查部位" :txt="rowCurr.examPart" style="width: 50%"/>
      <AppInfoItem label="金       额" :txt="rowCurr.cost" style="width: 50%"/>
      <AppInfoItem label="床       号" :txt="rowCurr.bedNo" style="width: 50%"/>
      <AppInfoItem label="地       址" :txt="rowCurr.address" style="width: 50%;"/>
      <AppInfoItem label="优   先   级" txt="" style="width: 50%">
        <el-tag v-if="rowCurr.emergency > 0 && rowCurr.emergencylabel !='普通' && rowCurr.emergencylabel" size="mini" effect="dark" :type="rowCurr.emergency && rowCurr.emergencylabel !='普通' ? 'danger': ''">{{rowCurr.grade}}</el-tag>
        <span v-else>{{rowCurr.emergencylabel}}</span>
        <i class="el-icon-edit" @click="editLevel(rowCurr.emergencylabel)" title="修改优先级" style="cursor: pointer;"></i>
        <el-checkbox class="mar-l-20" v-model="rowCurr.isVIP" @change="handleVIPChange">VIP</el-checkbox>
      </AppInfoItem>
      <AppInfoItem label="保密级别" style="width: 50%" v-permission="'YJYY10008051'">
        <el-select size="mini" ref="examClass" v-model="rowCurr.privacyLevel" filterable style="width:120px;" @change="changePrivacyLevel" clearable>
          <el-option
            v-for="(item, index) in privacyLevelList"
            :key="index"
            :value="item.value"
            :label="item.label"
          ></el-option>
        </el-select>
      </AppInfoItem>
      <AppInfoItem v-show="false" label="丙肝" txt="" style="width: 50%" v-if="['内窥镜', 'ES'].includes(rowCurr.dep)">
        <el-select :class="isHcv ? 'special-color' : ''" size="mini" v-model="defaultChoose.hcv" filterable style="width:120px;" clearable @change="changeHCV">
          <el-option
            v-for="(item, index) in hBSagOptions"
            :key="index"
            :value="item"
            :label="item"
          ></el-option>
        </el-select>
      </AppInfoItem>
      <AppInfoItem v-show="false" label="RPR" txt="" style="width: 50%" v-if="['内窥镜', 'ES'].includes(rowCurr.dep)">
        <el-select :class="isRpr ? 'special-color' : ''" size="mini" v-model="defaultChoose.rpr" filterable style="width:120px;" clearable @change="changeRPR">
          <el-option
            v-for="(item, index) in hBSagOptions"
            :key="index"
            :value="item"
            :label="item"
          ></el-option>
        </el-select>
      </AppInfoItem>
      <AppInfoItem v-show="false" label="HIV" txt="" style="width: 50%" v-if="['内窥镜', 'ES'].includes(rowCurr.dep)">
        <el-select :class="isHiv ? 'special-color' : ''" size="mini" v-model="defaultChoose.hiv" filterable style="width:120px;" clearable @change="changeHIV">
          <el-option
            v-for="(item, index) in hBSagOptions"
            :key="index"
            :value="item"
            :label="item"
          ></el-option>
        </el-select>
      </AppInfoItem>
      <AppInfoItem v-show="false" label="HBsAg" txt="" style="width: 50%" v-if="['内窥镜', 'ES'].includes(rowCurr.dep)">
        <el-select :class="isHbsag ? 'special-color' : ''" size="mini" v-model="defaultChoose.hbsag" filterable style="width:120px;" clearable @change="changeHBsAg">
          <el-option
            v-for="(item, index) in hBSagOptions"
            :key="index"
            :value="item"
            :label="item"
          ></el-option>
        </el-select>
      </AppInfoItem>
      <AppInfoItem v-show="false" label="PRG" txt="" style="width: 50%" v-if="['内窥镜', 'ES'].includes(rowCurr.dep)">
        <el-select :class="isPRG ? 'special-color' : ''" size="mini" v-model="defaultChoose.PRG" filterable style="width:120px;" clearable @change="changePRG">
          <el-option
            v-for="(item, index) in hBSagOptions"
            :key="index"
            :value="item"
            :label="item"
          ></el-option>
        </el-select>
      </AppInfoItem>
      <AppInfoItem v-show="false" label="SCR" txt="" style="width: 50%" v-if="['内窥镜', 'ES'].includes(rowCurr.dep)">
        <el-select :class="isSCR ? 'special-color' : ''" size="mini" v-model="defaultChoose.SCR" filterable style="width:120px;" clearable @change="changeSCR">
          <el-option
            v-for="(item, index) in hBSagOptions"
            :key="index"
            :value="item"
            :label="item"
          ></el-option>
        </el-select>
      </AppInfoItem>
      <!-- <AppInfoItem label="临床诊断" :txt="rowCurr.clinicdiagnosis" style="width: 100%;" min-height="60px"/> -->
      <AppInfoItem label="主       诉" :txt="rowCurr.clinicdiagnosis" style="width: 100%;" max-height="60px"/>
      <AppInfoItem label="检查备注" :txt="rowCurr.remarkInfo" style="width: 100%" item-txt-color="#f00">
        <i class="el-icon-edit" @click="editRemarkInfo(rowCurr.remarkInfo)" title="修改优先级" style="cursor: pointer;color:#000" v-if="isSetRemarkInfo"></i>
      </AppInfoItem>
      <AppInfoItem label="电子病史" txt="" style="width: 50%" max-height="116px">
        <span class="diseasesHistory" v-html="highlightedText(rowCurr.diseasesHistory)" :title="highlightedText(rowCurr.diseasesHistory)"></span>
      </AppInfoItem>
      <!-- <AppInfoItem label="电子病史" :txt="rowCurr.diseasesHistory" style="width: 100%;" min-height="60px"/> -->
      <AppInfoItem label="收费状态" :txt="rowCurr.feeStatus" style="width: 50%"/>
      <AppInfoItem label="申请单号" :txt="rowCurr.applyCode" style="width: 100%"/>
      <AppInfoItem label="急诊标志" :txt="rowCurr.emergencyInfo" style="width: 50%"></AppInfoItem>
    </div>
    <!-- <div class="bottomBox">
      <i class="el-icon-close fs-20" @click="handleClose"></i>
    </div> -->
  </div>
</template>
<script>
import applyInfo from '@/mixin/applyInfo'
export default {
  mixins: [applyInfo],
  props: {
    mipVisible: {
      type: Boolean,
      default: true
    }
  },
  created() {
    // console.log('mipVisible', this.mipVisible)
    // console.log('rowCurr', this.rowCurr)
    // solveTagColor(this.rowCurr.diseasesHistory)
  },
  data() {
    return {
      hBSagOptions: ['阴性', '阳性', '未检', '设置'],
      defaultChoose: {
        hbsag: '阴性',
        hiv: '阴性',
        rpr: '阴性',
        hcv: '阴性',
        PRG: '阴性',
        SCR: '阴性'
      }
    }
  },
  computed: {
  },
  watch: {
    'rowCurr.patientId': function (val) {
      if (val) {
        this.defaultChoose.hbsag = '阴性'
        this.defaultChoose.hiv = '阴性'
        this.defaultChoose.rpr = '阴性'
        this.defaultChoose.hcv = '阴性'
        this.defaultChoose.PRG = '阴性'
        this.defaultChoose.SCR = '阴性'
        this.isHbsag = false
        this.isHiv = false
        this.isHcv = false
        this.isRpr = false
        this.isPRG = false
        this.isSCR = false
      }
    }
  },
  mounted() {
    this.getPrivacyLevel()
  },
  methods: {
    highlightedText(diseasesHistory) {
      if (diseasesHistory) {
        return diseasesHistory.replace(/(阳性)/g, '<span style="color: red;">$1</span>')
      } else {
        return null
      }
    }
  }
}
</script>

<style lang="scss" scoped>
  .pat_info{
    padding: 0 10px 10px;
    .pat_info_item{
      display: flex;
      flex-wrap: wrap;
    }
  }
  .special-color >>> .el-input__inner {
      color: red !important;
  }
</style>
